<template>
  <div class="sex-box">
    <div class="title">
      <span>男女比例</span>
      <p class="bg"></p>
    </div>
    <div class="sex_">
      <div class="man">
        <img src="../../images/man.png" width="100%" alt="" />
      </div>
      <div class="woman">
        <img src="../../images/woman.png" width="100%" alt="" />
      </div>
    </div>
    <div class="bili">
      <p>男：40%</p>
      <p>女：60%</p>
    </div>
    <div class="charts_sex" ref="sex_charts"></div>
  </div>
</template>

<script lang="ts" setup>
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'

const sex_charts = ref()
onMounted(() => {
  let mychart = echarts.init(sex_charts.value)
  mychart.setOption({
    //组件标题
    title: {
      text: '男女比例', //主标题
      textStyle: {
        //主标题颜色
        color: 'skyblue',
      },
      left: '40%',
    },
    //x|y
    xAxis: {
      show: false,
      min: 0,
      max: 100,
    },
    yAxis: {
      show: false,
      type: 'category',
    },
    series: [
      {
        type: 'bar',
        data: [58],
        barWidth: 20,
        z: 100,
        itemStyle: {
          color: 'skyblue',
          borderRadius: 20,
        },
      },
      {
        type: 'bar',
        data: [100],
        barWidth: 20,
        //调整女士柱条位置
        barGap: '-100%',
        itemStyle: {
          color: 'pink',
          borderRadius: 20,
        },
      },
    ],
    grid: {
      left: 0,
      top: 0,
      right: 0,
      bottom: 0,
    },
  })
})
</script>

<style lang="scss" scoped>
.sex-box {
  .title {
    span {
      color: #29fcff;
      font-size: 20px;
    }
    .bg {
      width: 68px;
      height: 7px;
      background: url(../../images/dataScreen-title.png) no-repeat;
      background-size: 100% 100%;
      margin-top: 10px;
    }
  }
  .sex_ {
    width: 100%;
    height: 100px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 30px;
    .man {
      width: 100px;
      height: 100px;
      background: url(../../images/man-bg.png) no-repeat;
      background-size: 100% 100%;
      margin-right: 30px;
      img {
        width: 100%;
        height: 100%;
      }
    }
    .woman {
      width: 100px;
      height: 100px;
      background: url(../../images/woman-bg.png) no-repeat;
      background-size: 100% 100%;
      img {
        width: 100%;
        height: 100%;
      }
    }
  }
  .bili {
    display: flex;
    justify-content: space-between;
    color: #29fcff;
    font-size: 20px;
    padding: 15px 10px;
  }
  .charts_sex {
    width: 100%;
    height: 100px;
  }
}
</style>
